<template>
	<el-dialog title="查看充值订单" v-model="visible" :width="600" destroy-on-close @closed="$emit('closed')">
		<el-descriptions :column="2" border>
			<el-descriptions-item label="订单ID">{{form.id}}</el-descriptions-item>
			<el-descriptions-item label="订单号">{{form.ordernum}}</el-descriptions-item>
			<el-descriptions-item label="会员ID">{{form.member_id}}</el-descriptions-item>
			<el-descriptions-item label="充值金额">{{form.amount}}元</el-descriptions-item>
			<el-descriptions-item label="赠送金额">{{form.give}}元</el-descriptions-item>
			<el-descriptions-item label="总金额">{{(parseFloat(form.amount) + parseFloat(form.give)).toFixed(2)}}元</el-descriptions-item>
			<el-descriptions-item label="支付方式">{{form.pay_type}}</el-descriptions-item>
			<el-descriptions-item label="状态">
				<el-tag :type="getStatusTagType(form.status)">{{form.status}}</el-tag>
			</el-descriptions-item>
			<el-descriptions-item label="第三方单号">{{form.tordernum || '暂无'}}</el-descriptions-item>
			
			<el-descriptions-item label="创建时间" :span="2">{{form.create_time}}</el-descriptions-item>
			<el-descriptions-item label="更新时间" :span="2">{{form.update_time}}</el-descriptions-item>
		</el-descriptions>
		<template #footer>
			<el-button @click="visible=false">关 闭</el-button>
		</template>
	</el-dialog>
</template>

<script>
	export default {
		emits: ['closed'],
		data() {
			return {
				visible: false,
				form: {
					id: '',
					ordernum: '',
					member_id: '',
					amount: 0,
					give: 0,
					pay_type: '',
					status: '',
					tordernum: '',
					taskid: '',
					create_time: '',
					update_time: ''
				}
			}
		},
		mounted() {

		},
		methods: {
			//显示
			open(){
				this.visible = true;
				return this
			},
			//获取状态标签类型
			getStatusTagType(status) {
				const typeMap = {
					'支付中（待审核）': 'warning',
					'支付成功': 'success',
					'支付失败': 'danger',
					'已取消': 'info'
				}
				return typeMap[status] || 'info'
			},
			//表单注入数据
			setData(data){
				this.form = { ...data }
			}
		}
	}
</script>

<style>
</style>
